import React from 'react'
import { connect} from '../react-redux'
import actionCreators  from '../store/actionCreators/counter2';


 class Counter3 extends React.Component {

    render(){
        const { number,add2,minus2 } = this.props
        return (
            <div>
                <p>{number}</p>
                {/* <button onClick={()=>store.dispatch(add())}>+</button>
                <button onClick={()=>store.dispatch(minus())}>-</button> */}
                <button onClick={add2}>+</button>
                <button onClick={minus2}>-</button>
            </div>
        )
    }
}
/**
 * state = {counter1:{number:0},counter2:{number:0}}
 * 组件和仓库的关系
 * 输入：取总总状态的某一部分通过props输入到组件中
 * 输出 : 把actionCreators通过 props传到组件中
 */
const mapStateToProps = (state)=>state.counter2
export default connect(
    mapStateToProps,
    actionCreators
)(Counter3)